<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.springframework.org/schema/mvc">
<head>
    <meta charset="UTF-8">
    <title>签到管理</title>
    <!--<link rel="stylesheet" href="layui/css/layui.css">-->
</head>
<body>
<!--面包屑导航-->
<div class="layui-card" style="padding: 15px">
    <div class="layui-breadcrumb">
        <a href="javascript:;">首页</a>
        <a href="javascript:;">
            <cite>签到管理</cite>
        </a>
    </div>
</div>
<div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
        <table id="course_table" lay-filter="course" class="layui-table">
            <thead class="layui-table-header">
            <tr>
                <th></th>
                <th>星期一</th>
                <th>星期二</th>
                <th>星期三</th>
                <th>星期四</th>
                <th>星期五</th>
            </tr>
            </thead>
            <tbody class="layui-table-body">
            <tr id="c1">
                <td>1</td>
                <td class="cla" courseTime="1,1"></td>
                <td class="cla" courseTime="2,1"></td>
                <td class="cla" courseTime="3,1"></td>
                <td class="cla" courseTime="4,1"></td>
                <td class="cla" courseTime="5,1"></td>
            </tr>
            <tr id="c2">
                <td>2</td>
                <td class="cla" courseTime="1,2"></td>
                <td class="cla" courseTime="2,2"></td>
                <td class="cla" courseTime="3,2"></td>
                <td class="cla" courseTime="4,2"></td>
                <td class="cla" courseTime="5,2"></td>
            </tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>

            <tr id="c3">
                <td>3</td>
                <td class="cla" courseTime="1,3"></td>
                <td class="cla" courseTime="2,3"></td>
                <td class="cla" courseTime="3,3"></td>
                <td class="cla" courseTime="4,3"></td>
                <td class="cla" courseTime="5,3"></td>
            </tr>
            <tr id="c4">
                <td>4</td>
                <td class="cla" courseTime="1,4"></td>
                <td class="cla" courseTime="2,4"></td>
                <td class="cla" courseTime="3,4"></td>
                <td class="cla" courseTime="4,4"></td>
                <td class="cla" courseTime="5,4"></td>
            </tr>

            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>

            <tr id="c5">
                <td>5</td>
                <td class="cla" courseTime="1,5"></td>
                <td class="cla" courseTime="2,5"></td>
                <td class="cla" courseTime="3,5"></td>
                <td class="cla" courseTime="4,5"></td>
                <td class="cla" courseTime="5,5"></td>
            </tr>

            </tbody>
        </table>
    </div>
    <div class="layui-tab-item">
        <table id="course_table_list" lay-filter="course"></table>
    </div>
</div>
<script src="js/axios.min.js" th:src="@{/js/axios.min.js}"></script>
<script src="js/vue.min.js" th:src="@{/js/vue.min.js}"></script>
<script>

    axios.get("/course/AllCourse")
        .then(function (response) {
            var data = response.data.data;
            for (var i = 0; i < data.length; i++) {
                var time = data[i].courseTime
                var aarrTime2 = time.split(",")
                var tr = document.getElementById("c" + aarrTime2[1])
                var tds = tr.getElementsByTagName("td")
                var jie = parseInt(aarrTime2[0])
                tds[jie].innerHTML = data[i].courseNumber;
                tds[jie].addEventListener("click", addClasseLayer);

                tds[jie].setAttribute("courseId",data[i].courseId)

                // for (var j = 0; j < aarrTime.length; j++) {
                //     var aarrTime2 = aarrTime[j].split(",")
                //     console.log("c" + aarrTime2[0])
                //     var tr = document.getElementById("c" + aarrTime2[1])
                //     var tds = tr.getElementsByTagName("td")
                //     //  console.log(aarrTime2[1]+1)
                //     var jie = parseInt(aarrTime2[0])
                //     tds[jie].innerHTML = data[i].courseNumber;
                //     //console.log(aarrTime2)
                // }
            }
            console.log(data);
        })
        .catch(function (error) {
            console.log(error);
        });


    function addClasseLayer(even) {
       var target=  even.target
        console.log(target.getAttribute("courseId"))
        console.log(target.getAttribute("courseTime"))
       // window.location.href="127.0.0.1"
        $("#layui-body").load("index")
    }
</script>
</body>
</html>